//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_linemaker2.sqf"
#include "x_setup.sqf"

// _p1 and _p2 = positions, _mname = marker name
private ["_p1", "_p2", "_mname", "_dist", "_radius", "_dir", "_dirn", "_x1", "_y1", "_curnum"];
PARAMS_3(_p1,_p2,_mname);
_dist = _p1 distance _p2;
_radius = _dist / 2;
_dir = [_p1, _p2] call FUNC(DirTo);
_dirn = _dir + 180;
_x1 = (_p1 select 0) - (_radius * sin _dirn);
_y1 = (_p1 select 1) - (_radius * cos _dirn);
_mpos = markerPos _mname;
if ((_mpos select 0) == 0 && {(_mpos select 1) == 0} && {(_mpos select 2) == 0}) then {
	[_mname,[_x1, _y1],"RECTANGLE","ColorBlack",[_dist / 2, 0.9],"",_dir + 90] call FUNC(CreateMarkerLocal);
} else {
	_mname setMarkerPosLocal [_x1, _y1];
	_mname setMarkerSizeLocal [_dist / 2, 0.9];
	_mname setMarkerDirLocal _dir + 90;
};